package com.love.cloud.common.dubbo.filter;//package com.love.cloud.common.dubbo.filter;
//
//import lombok.extern.slf4j.Slf4j;
//import org.apache.dubbo.common.constants.CommonConstants;
//import org.apache.dubbo.common.extension.Activate;
//import org.apache.dubbo.rpc.*;
//
//import java.util.HashMap;
//import java.util.Map;
//import java.util.concurrent.CompletableFuture;
//
//
///**
// * 提供者过滤器
// * @author hongdongqu
// */
//@Slf4j
//@Activate(group = CommonConstants.PROVIDER)
//public class DubboProviderFilter implements Filter{
//
//    @Override
//    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
//        Map<String, String> attachments = invocation.getAttachments();
//        if(attachments!=null){
//            attachments=new HashMap<String,String>(attachments);
//            attachments.remove(CommonConstants.PATH_KEY);
//            attachments.remove(CommonConstants.GROUP_KEY);
//            attachments.remove(CommonConstants.VERSION_KEY);
//            attachments.remove(CommonConstants.DUBBO_VERSION_KEY);
//            attachments.remove(CommonConstants.TIMEOUT_KEY);
//        }
//        RpcContext.getContext()
//                .setInvoker(invoker)
//                .setInvocation(invocation)
//                .setAttachments(attachments)
//                .setLocalAddress(invoker.getUrl().getHost(),invoker.getUrl().getPort());
//        if(invocation instanceof RpcInvocation){
//            ((RpcInvocation)invocation).setInvoker(invoker);
//        }
//        try{
//            return invoker.invoke(invocation);
//        }finally {
//            RpcContext.removeContext();
//        }
//
//    }
//}
